package com.dw.widget.slideshow2.utils;

import com.dw.widget.slideshow2.utils.ClipQueue.ImageClip;
import com.dw.widget.slideshow2.utils.log.Log;
import com.dw.widget.slideshow2.R;

import android.app.Application;
import android.os.Environment;
import android.widget.RemoteViews;

public class ApplicationEx extends Application {

	private static ApplicationEx _instance;
	public static ApplicationEx INSTANCE()
	{
		return _instance;
	}
	
	@Override
	public void onCreate() {

		super.onCreate();
		
		// 设置日志Level
		Log.LOGLEVEL = Log.LEVEL_FILE;
		
		// 设置自定义异常处理
		CrashHandler.Instance().init(getApplicationContext());
		
		_instance = this;
	}

	// INTENT MESSAGE NAME
	public final String INTENT_MSG_APPWIDGETIDS = "app_widget_ids";
	public final String INTENT_MSG_SERVICECOMMAND = "service_command";
	public final String INTENT_MSG_FULLPATH = "full_path";
	
	// THREAD MSG CONSTANTS
	public final int THREAD_MSG_ADDCLIP = 0x8C32001;
	public final int THREAD_MSG_SCANFOLDER = 0x8C32002;
	public final int THREAD_MSG_ADDINIT = 0x8C32003;
	
	// THREAD MSG PARA
	public final String THREAD_PARA_INITADDED = "init_added";
	public final String THREAD_PARA_SCANEDNUM = "scaned_number";
	public final String THREAD_PARA_SCANEDTOTAL = "scaned_total";
	
	// SERVICE COMMAND
	public final int SERVICE_CMD_STARTWIDGET = 0xC4AD001;
	public final int SERVICE_CMD_SWITCHCLIP = 0xC4AD002;
	public final int SERVICE_CMD_STOPWIDGET = 0xC4AD003;
	public final int SERVICE_CMD_PAUSEWIDGET = 0xC4AD004;
	
	// BROADCAST CONSTANTS
	public final int SWITCH_BROADCAST_REQCODE = 0xA8C1001; 
	public final String BROADCAST_INTENT_CMD = "broadcast_timer";
	public final int BROADCAST_INTENT_TIMER = 0x8E17001;
	
	// DB CONSTANTS
	public final String DB_NAME = "slide_widget.db";
	
	// OTHER GLOBAL VALUES
	public int LAST_SWITCH_LAYOUT = R.layout.widget_ex_fade_1;    // 上一次切换布局id
	public ImageClip LAST_CLIP_IN = null;     // 上一次进入的CLIP
	public ImageClip LAST_CLIP_OUT = null;    // 上一次出的CLIP
	public RemoteViews WIDGET_VIEW = null;
		
	public final String YES = "Y";
	public final String NO = "N";
	
	public final String HORIZONTAL = "H";
	public final String VERTICAL = "V";

	// WIDGET SIZE IN DP
	public final int WIDGET_WIDHT_DP = 294;
	public final int WIDGET_HEIGHT_DP = 146;
	
	// WIDGET SEIZ IN PX
	public int widgetWidthPx = 0;
	public int widgetHeightPx = 0;
	
	// IMAGE PATH
	public final String DATA_FOLDER = ".SlidePhotoWidget";
	public final String IMAGE_DIR = CommonUtils.getDCIMPath();
	public final String CLIP_DIR = Environment.getExternalStorageDirectory() + "/" + DATA_FOLDER + "/clips/";
	
	public final String CLIP_SUFFIX = ".clips";
	
	public ClipQueue CLIP_QUEUE = new ClipQueue(8);
	public ImageDataCache IMAGE_CACHE = new ImageDataCache();
	
	public Object DB_MODIFY_LOCK = new Object();     // 数据库访问控制
	
	public String CONFIG_FILE_NAME = "app_config";
	public int INIT_ADD_NUMBER = 3;     // 初始添加的图片数量
	
	public String CONFIGURATION_DONE = "configuration_done";     // widget配置完成
	public String FIRST_INIT_RUN = "first_init";     // 首次初始化
	
	public String STATUS_TEXT;       // 状态文字
	
	/**
	 * 对应ScanFolderData source来源字段
	 */
	public final String SOURCE_CAMERA = "cam";
	public final String SOURCE_FOLDER = "fdr";
	public final String SOURCE_FLICKR = "flr";
	
	/**
	 * 相框样式常量
	 */
	public static final int FRAME_STYLE1 = 0x9C6A001;
	public static final int FRAME_STYLE2 = 0x9C6A002;
	public static final int FRAME_STYLE3 = 0x9C6A003;
	public static final int FRAME_STYLE4 = 0x9C6A004;
	public static final int FRAME_STYLE5 = 0x9C6A005;
	public static final int FRAME_STYLE6 = 0x9C6A006;
	public static final int FRAME_STYLE7 = 0x9C6A007;
	public static final int FRAME_STYLE8 = 0x9C6A008;
	public static final int FRAME_STYLE9 = 0x9C6A009;
	
	/**
	 * 动画样式常量
	 */
	public static final int ANIMATION_STYLE1 = 0x2EC1001;
	public static final int ANIMATION_STYLE2 = 0x2EC1002;
	public static final int ANIMATION_STYLE3 = 0x2EC1003;
	public static final int ANIMATION_STYLE4 = 0x2EC1004;
	public static final int ANIMATION_STYLE5 = 0x2EC1005;
	public static final int ANIMATION_STYLE6 = 0x2EC1006;
	public static final int ANIMATION_STYLE7 = 0x2EC1007;
	
	/**
	 * 设置项
	 */
	public final String CONFIG_ITEM_CAMERA = "camera";
	public final String CONFIG_ITEM_FLICKR = "flickr";
	public final String CONFIG_ITEM_FRAME = "frame";
	public final String CONFIG_ITEM_ANIMATION = "animation";
	
	// Professional版包名
	public final String PROFESSIONAL_PACKAGE_NAME = "com.dw.widget.slideshow.unlock";
	public boolean isProfessional = false;
	
}
